<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	View application
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="HeadContent" runat="server">

	<script type="text/javascript">

		$(document).ready(function() {
			// alert('ready.');
			setInterval('reloadMailTable()', 2000);
		});

		function reloadMailTable() {
			// $('#mailtable')[0].innerHTML = 'Loading...';
			var dt = new Date();
			$('#mailtable').load('<%= Mailer.Utilities.Configuration.RelativeRootURL %>applications/PartialMailListTable/<%= ViewData["ID"] %>?dummy=' + escape(dt.toString()));
		}

	</script>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
	<div class="pagetitle">
		<h1>
			Application: <em>
				<%= ViewData[ "name" ] %></em></h1>
	</div>
	<div class="pagecontent">
		<p>
			<b>All mails:</b>
		</p>
		<div id="mailtable">
			<table style="width: 100%;">
				<tr>
					<th>
						Mail
					</th>
					<th>
						Created date
					</th>
					<th>
					</th>
				</tr>
				<% foreach (var m in ViewData["Mails"] as IList<Mailer.Model.Types.Mail>)
	   { %>
				<tr>
					<td>
						<%= Html.ActionLink(m.Name, "View", "Mail", new { Id = m.ID }, null)%>
					</td>
					<td>
						<%= m.CreatedDate %>
					</td>
					<td>
						<%= Html.ActionLink("Edit", "Edit", "Mail", new { Id = m.ID }, null)%>
					</td>
				</tr>
				<% } %>
			</table>
		</div>
		<p>
			<%= Html.ActionLink( "Create mail", "New", "Mail", new { application = ViewData[ "ID" ] }, null ) %>
		</p>
	</div>
</asp:Content>
